<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>销售信息管理</title> <!-- 修正页面标题 -->
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: url('/images/2.jpg') no-repeat center center fixed;
            background-size: cover;
            font-family: "微软雅黑", sans-serif;
        }

        .main-content {
            margin-left: 200px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.5);
            min-height: calc(100vh - 50px);
        }

        .breadcrumb {
            margin-bottom: 20px;
            color: #999;
        }

        .breadcrumb a {
            color: #000;
            text-decoration: none;
        }

        .breadcrumb a:hover {
            text-decoration: underline;
        }

        .breadcrumb .current-page {
            color: #000;
        }

        .search-bar {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        .search-bar input {
            padding: 5px 8px;
            border: 1px solid #ccc;
            border-radius: 3px;
            margin-right: 10px;
        }
        .search-bar button {
            padding: 5px 15px;
            background-color: #1773d0;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .btn-group {
            margin-bottom: 15px;
        }
        .btn-group button {
            padding: 6px 12px;
            margin-right: 10px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            color: #fff;
        }
        .btn-add {
            background-color: #5cb85c;
        }
        .btn-delete {
            background-color: #d9534f;
        }

        .table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }
        .table thead {
            background-color: #902d2d;
            color: #fff;
        }
        .table th, .table td {
            border: 1px solid #ddd;
            padding: 8px 10px;
            text-align: center;
        }
        .table tbody tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        .operate-btn {
            padding: 4px 8px;
            margin: 0 2px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            color: #fff;
        }
        .btn-edit {
            background-color: #f0ad4e;
        }
        .btn-remove {
            background-color: #d9534f;
        }

        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #9b2222;
            color: #fff;
            padding: 10px 20px;
        }
        .sidebar {
            width: 200px;
            background-color: #fff;
            float: left;
            height: calc(100vh - 50px);
            padding-top: 20px;
            border-right: 1px solid #eee;
        }
        .sidebar li {
            padding: 12px 20px;
            cursor: pointer;
        }
        .sidebar li:hover {
            background-color: #ddd;
        }
        .sidebar li.active {
            background-color: #ddd;
            font-weight: bold;
        }
    </style>
</head>

<body>
<!-- 引入顶部导航栏 -->
<div th:replace="~{common/common::topbar}"></div>

<!-- 引入侧边栏 -->
<div th:replace="~{common/common::sidebar}"></div>

<!-- 主体内容区域 -->
<div class="main-content">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
        <a href="/login.html">系统首页</a> > <span class="current-page">销售信息管理</span> <!-- 修正标题 -->
    </div>

    <!-- 搜索栏（修改为搜索收支描述） -->
    <div class="search-bar">
        <label for="searchInput">搜索：</label>
        <input type="text" id="searchInput" placeholder="请输入收支描述">
        <button>查询</button>
    </div>

    <!-- 按钮组 -->
    <div class="btn-group">
        <button class="btn-add">新增</button>
        <button class="btn-delete">删除</button>
    </div>

    <!-- 财务记录表格 -->
    <table class="table">
        <thead>
        <tr>
            <th><input type="checkbox"></th>
            <th>ID</th>
            <th>收支日期</th>
            <th>收入金额</th>
            <th>支出金额</th>
            <th>收支描述</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <!-- 循环展示财务记录数据 -->
        <tr th:each="record : ${financialLists}"> <!-- 绑定财务记录列表数据 -->
            <td><input type="checkbox"></td>
            <td th:text="${record.id}">1</td> <!-- ID -->
            <td th:text="${#dates.format(record.recordDate, 'yyyy-MM-dd HH:mm')}">2023-01-01 10:00</td> <!-- 格式化日期时间 -->
            <td th:text="${record.income}">1000.00</td> <!-- 收入金额 -->
            <td th:text="${record.expense}">500.00</td> <!-- 支出金额 -->
            <td th:text="${record.description}">销售92号汽油</td> <!-- 收支描述 -->
            <td>
                <button class="operate-btn btn-edit">修改</button>
                <button class="operate-btn btn-remove">删除</button>
            </td>
        </tr>
        <!-- 无数据时显示 -->
        <tr th:if="${financialLists == null or financialLists.isEmpty()}">
            <td colspan="7" class="text-center">暂无财务记录信息</td>
        </tr>
        </tbody>
    </table>
</div>

<script>
    // 设置侧边栏"销售信息管理"为激活状态
    document.addEventListener('DOMContentLoaded', function() {
        const sidebarItems = document.querySelectorAll('.sidebar li');
        sidebarItems.forEach(item => {
            // 匹配侧边栏中"销售信息管理"的文本（根据实际配置调整）
            if (item.textContent.trim() === '销售信息管理') {
                item.classList.add('active');
            }
        });
    });
</script>
</body>
</html>
